package ru.st.selenium.applogic2;

import java.util.List;

import ru.st.selenium.applogic.FilmHelper;
import ru.st.selenium.model.Film;

public class FilmHelper2 extends DriverBasedHelper implements FilmHelper {

  public FilmHelper2(ApplicationManager2 manager) {
    super(manager.getWebDriver());
  }

  @Override
  public void create(Film film) {
	  pages.addMoviePage.ensurePageLoaded()
	  .setMovieTitle(film.getTitle())
	  .setMovieYear(film.getYear())
	  .saveMovie();
  }
  
  @Override
  public boolean movieIsPresent(Film film) {
	  return pages.internalPage.ensureMainPageLoaded().movieIsPresent(film);
  }

  @Override
  public boolean requiredFieldErrorMessagePresent(String field) {
	  return pages.addMoviePage.requiredFieldErrorMessagePresent(field);
  }
  
  @Override
  public void delete() {
	  pages.moviePage.removeMovie();
  }

  @Override
  public List<Film> searchWithResults(String title) {
    return pages.internalPage.ensurePageLoaded().searchWithResults(title);
  }
  
  @Override
  public boolean searchWithoutResults(String title) {
    return pages.internalPage.ensurePageLoaded().searchWithoutResults(title);
  }

}
